global projectdir "~"
global datadir "$projectdir/data"


log using "$projectdir/logs/placebo_event_study.do", text replace


****************************************************************
****************************************************************

cd $datadir/hightech_entre_placebo
use industry_analysis_file, clear

gen event_year_ = abs(event_year)
tab event_year_ if event_year < 0, gen(lag)
tab event_year_ if event_year == 0, gen(lead)
rename lead1 lead0
tab event_year_ if event_year > 0, gen(lead)
mvencode lag* lead*, mv(0) override

su event_year_ if event_year < 0
local max_pre_period = r(max)
local lag_order = ""
forvalues i = `max_pre_period'(-1)1 {
local lag_order = "`lag_order'" + " lag`i'"
*display in red "`lag_order'"
}
order `lag_order' lead*, last
drop event_year_
drop lag1

*by naics_n, sort: gen l1_ihs_lbdfids = ihs_lbdfids[_n - 1]

*eventdd ihs_start i.year, hdfe absorb(i.naics_n) cluster(naics_n) timevar(event_year) ci(rcap) leads(6) lags(6) accum noend
*eventdd ihs_start i.year c.ihs_lbdfids, hdfe absorb(i.naics_n) cluster(naics_n) timevar(event_year) ci(rcap) leads(6) lags(6) accum noend
*eventdd ihs_start i.year c.l1_ihs_lbdfids, hdfe absorb(i.naics_n) cluster(naics_n) timevar(event_year) ci(rcap) leads(6) lags(6) accum noend

*eventdd ihs_start i.year, hdfe absorb(i.naics_n) cluster(naics_n) timevar(event_year) ci(rcap)
*eventdd ihs_start i.year c.ihs_lbdfids, hdfe absorb(i.naics_n) cluster(naics_n) timevar(event_year) ci(rcap)
*eventdd ihs_start i.year c.l1_ihs_lbdfids, hdfe absorb(i.naics_n) cluster(naics_n) timevar(event_year) ci(rcap)

eststo clear
eststo: reghdfe ihs_start i.year lag* lead*, cluster(naics_n) absorb(i.naics_n)
eststo: reghdfe ihs_start i.year lag* lead* c.ihs_lbdfids, cluster(naics_n) absorb(i.naics_n)
eststo: reghdfe ihs_start i.year lag* lead* c.l1_ihs_lbdfids, cluster(naics_n) absorb(i.naics_n)
esttab using "$projectdir/hightech_entre_placebo/Staudt_Industry_HT_Placebo_EventStudy_Export.csv", replace b(%8.4g) se(%8.4g) keep(lag6 lag5 lag4 lag3 lag2 lead0 lead1 lead2 lead3 lead4 lead5 lead6)


****************************************************************
****************************************************************


log close



